00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef DE_FILE_HPP
00029 #define DE_FILE_HPP
00030
00031 #include "deGlobalTypes.hpp"
00032
00033 #if defined(DEFILE_DLL_EXPORTS) || defined(DESTINY3D_EXPORT_ALL)
00034 # define DEFILE_API extern "C" DEDLL_EXPORT
00035 #elif defined(DESTINY3D_STATIC_LINK)
00036 # define DEFILE_API extern "C"
00037 #else
00038 # define DEFILE_API extern "C" DEDLL_IMPORT
00039 #endif
00040
00041 #ifdef USING_DESTINY3D
00042 #ifdef _DEBUG
00043 # ifdef DESTINY3D_STATIC_LINK
00044 # pragma comment(lib, "deFile_sd")
00045 # else
00046 # pragma comment(lib, "deFiled")
00047 # endif //DESTINY3D_STATIC_LINK
00048 #else
00049 # ifdef DESTINY3D_STATIC_LINK
00050 # pragma comment(lib, "deFile_s")
00051 # else
00052 # pragma comment(lib, "deFile")
00053 # endif //DESTINY3D_STATIC_LINK
00054 #endif //_DEBUG
00055 #endif //USING_DESTINY3D
00056
00057
00058
00059
00060 class IdeFile;
00061 class IdeFileMemory;
00062 class IdeFilePlugin;
00063 class IdeFileVirtual;
00064 class IdeFileReal;
00065
00066 class IdePlugin;
00067 class IdeFileSystem;
00068
00069
00070
00071
00072 extern "C"
00073 {
00074
00075
00076 DEFILE_API IdeFileMemory* IdeFile_CreateFileMemory();
00077
00078 DEFILE_API IdeFilePlugin* IdeFile_CreateFilePlugin();
00079 }
00080
00081
00082
00083
00084
00085
00086 typedef struct deFileProperties
00087 {
00088 const char * Filename;
00089 unsigned long Size;
00090 s64 Time;
00091 long Flags;
00092 } deFileProperties;
00093
00094
00095
00096
00097
00098
00099 #define deFile_Seek_Start IdeFile::SEEKF_START
00100 #define deFile_Seek_End IdeFile::SEEKF_END
00101 #define deFile_Seek_Current IdeFile::SEEKF_CURRENT
00102
00103
00104 const long deFile_Open_Create =0x00000001;
00105 const long deFile_Open_Existing =0x00000002;
00106 const long deFile_Open_Always =0x00000003;
00107 const long deFile_Open_CreateAlways =0x00000004;
00108
00109
00110 const long deFile_Open_Read =0x00000010;
00111 const long deFile_Open_Write =0x00000020;
00112
00113
00114 const long deFile_Directory =0x00000001;
00115
00116
00117
00118
00119
00120
00121
00122 DE3D_INTERFACE_(IdeFile)
00123 {
00124 protected:
00125 virtual ~IdeFile() {}
00126
00127 public:
00128 enum Seek
00129 {
00130 SEEKF_START = 0,
00131 SEEKF_END,
00132 SEEKF_CURRENT,
00133 SEEK_COUNT,
00134 SEEK_FORCE_32BIT = 0x7FFFFFFF
00135 };
00136
00137 enum interface_t
00138 {
00139 iface_IdeFile = 0,
00140 iface_IdeFileReal,
00141 iface_IdeFileMemory,
00142 iface_IdeFileVirtual,
00143 iface_IdeFilePlugin,
00144 iface_force_32bit = 0x7FFFFFFF
00145 };
00146 virtual void* GetInterface(IdeFile::interface_t i) = 0;
00147
00148
00149 virtual int Release() = 0;
00150
00151
00152 virtual deBoolean Open(IdeFileSystem *BaseFS, char *Filename, long OpenFlags) = 0;
00153
00154
00155 virtual deBoolean Close() = 0;
00156
00157
00158 virtual long Read(void *Buffer, long Length) = 0;
00159
00160 virtual long Write(void *Buffer, long Length) = 0;
00161
00162
00163 virtual long GetPosition() = 0;
00164
00165 virtual long SetPosition(long NewPosition, IdeFile::Seek SeekType) = 0;
00166
00167
00168 virtual long GetSize() = 0;
00169
00170 virtual deBoolean SetSize(long NewSize) = 0;
00171
00172
00173 virtual s64 GetTime() = 0;
00174
00175 virtual deBoolean SetTime(s64 Time) = 0;
00176
00177
00178 virtual deBoolean GetProperties(deFileProperties *Properties) = 0;
00179
00180
00181 virtual long GetOpenFlags() = 0;
00182 };
00183
00184
00185
00186
00187 DE3D_INTERFACE(IdeFileMemory, IdeFile)
00188 {
00189 protected:
00190 ~IdeFileMemory() {}
00191
00192 public:
00193
00194
00195 virtual deBoolean Open() = 0;
00196 virtual deBoolean Open(long Length) = 0;
00197 virtual deBoolean Open(void *Buffer, long Length) = 0;
00198 virtual deBoolean Open(IdeFile *BaseFile) = 0;
00199
00200
00201
00202
00203 virtual deBoolean Open(IdeFileSystem *BaseFS, char *Filename, long OpenFlags) = 0;
00204 };
00205
00206
00207
00208 DE3D_INTERFACE(IdeFileVirtual, IdeFile)
00209 {
00210 protected:
00211 ~IdeFileVirtual() {}
00212 };
00213
00214
00215
00216
00217 DE3D_INTERFACE(IdeFileReal, IdeFile)
00218 {
00219 protected:
00220 ~IdeFileReal() {}
00221 };
00222
00223
00224
00225
00226 DE3D_INTERFACE(IdeFilePlugin, IdeFile)
00227 {
00228 protected:
00229 ~IdeFilePlugin() {}
00230
00231 public:
00232 virtual deBoolean Open(IdeFile *BaseFile) = 0;
00233
00234
00235
00236
00237 virtual deBoolean Open(IdeFileSystem *BaseFS, char *Filename, long OpenFlags) = 0;
00238
00239 virtual deBoolean AddPlugin(IdePlugin *Plugin) = 0;
00240 virtual deBoolean ReleasePlugin(IdePlugin *Plugin) = 0;
00241 virtual deBoolean ReleaseAllPlugins() = 0;
00242
00243
00244 virtual deBoolean DefragFile() = 0;
00245 };
00246
00247 #endif
00248